(A) Field of the Invention
The present invention relates to a router and a method for the router to transmit packets, and more particularly, to a method with two transmission modes for the router to transmit packets.
(B) Description of the Related Art
The Transport Control Protocol/Internet Protocol (TCP/IP) has been widely used in today's Internet technology. A TCP/IP-based Internet provides a datagram transmitting system between network devices such as hosts, and servers connected to an Internet. FIG. 1 is a schematic diagram of an Internet 10. The Internet 10 comprises Local Area Networks (LANs) 12, 22, 32 and a Wide Area Network (WAN) 16, interconnected by routers 18, 28 and 38. The hosts 14 and 16 are located in the network domain 40, while the hosts 34 and 36 are located in another network domain 42.
Routers 18, 28 and 38 each comprises an embedded routing table for recording routing paths about what networks are reachable. FIG. 2 is a schematic diagram of a routing table 100. As shown in FIG. 2, the routing table 100 comprises a destination address field 102, a mask address field 104, a gateway address field 106, an MAC address field 108 and an interface field 110. When a router receives a packet, it checks whether the network portion of the destination address in the packet is directly connected to the router. If the result is positive, the router will deliver the packet directly to the destination host. Otherwise, the router selects a routing path from its embedded routing table, and sends the packet directly to the next router through which the destination network is reachable.
FIG. 3 is a schematic diagram showing the format of an Internet network packet. As shown in FIG. 3, when a datagram is transmitted from the host 14 (a source host) to the host 34(a destination host), the address of the host 34 is specified as the destination address of the datagram. The datagram is then enveloped with a header to form a packet and sent to the router 18 connected to the same network (LAN 12) as the source host 14. When receiving the packet, the router 18 reads the destination address from the header of the packet, selects the next router that can route to the destination host, e.g., router 28, and transmits the packet to the next router 28. This process continues until the packet reaches the network to which the destination host 34 is connected, i.e., LAN 32, wherein the router 32 connected to the LAN 32 directly delivers the packet to the destination host 34.
The Network Address Translation (NAT) is one of the solutions for running out of Internet Protocol (IP) addresses. According to the NAT technology, a private addresses is used for a datagram to be transmitted within a network domain, and the private address is translated into a public addresses only when the datagram is to be transmitted to the outside of the network domain. Since the number of hosts to be connected outside of the network domain at the same time is smaller than the total number of hosts in the network domain, the lack of IP address can be resolved by assigning the public address to the host for connecting to the outside of the network domain and withdraw the assignment when the host terminates the connection.
FIG. 4 is a flow chart showing the operation of a router with the NAT function. Referring to FIG. 1, according to the NAT solution, the host 14 specifies its private address as the source address and the address of the host 34 as the destination address when transmitting a datagram to the host 34 via router 18. When receiving the packet from the host 14, the router 18 checks whether the destination address of the packet is within the network domain 40. If the result is positive, it is not necessary to transmit the packet outwardly and the router 18 will discard the packet. If the checking result is negative, the router 18 selects a routing path to the destination address from the routing table and replaces the private address of host 14 recorded in the source address field of the packet with the public address of the router 18, as shown in FIG. 5. The router 18 recalculates the header checksum and forwards the packet to the next router via WAN 30. Ultimately, router 38 receives the packet and delivers the packet to host 34.
In the above-mentioned operation procedure, selecting a routing path to a destination host from the routing table is the most time-consuming for a router between receiving the packet from the LAN and transmitting the packet to the WAN. Besides, all packets transmitted from the Intranet to Internet need to perform the above-mentioned operation procedure. Therefore, how to reduce the time for selecting a route is essential to the enhancement of the router's performance.